# _*_ coding：UTF-8 _*_
# 开发人员：lgm
# 开发时间：2021/6/10 13:37
# 文件名称：run_method2.PY
# 开发工具：PyCharm
# _*_ coding：UTF-8 _*_
# 开发人员：lgm
# 开发时间：2021/6/10 10:44
# 文件名称：run_method.PY
# 开发工具：PyCharm
import time,os,sys
file_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__name__))))
from random import randint
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
email = str(randint(10000000,9999999999))+"yimei@qq.com"
officeTelephone = "010-"+str(randint(111111111,999999999))
ti_sum1 = 20
ti_sum2 = 35
ti_sum3 = 40

ti_list1 = []
ti_list2 = []
ti_list3 = []

d2_sum1 = 15
d2_sum2 = 15
d2_sum3 = 20
d2_sum4 = 10
d2_sum5 = 15

d2_list1 = []
d2_list2 = []
d2_list3 = []
d2_list4 = []
d2_list5 = []
jigou_id = randint(111111111,999999999)
mobile_nub = randint(13711111111,13999999999)
yzm="123"
def register_pop(driver):
    driver.get("http://192.168.1.242:8034")
    driver.maximize_window()


    driver.find_element(By.XPATH, "/html/body/div[2]/input").click()
    driver.implicitly_wait(20)
    driver.find_element(By.NAME, "unitcode").send_keys(jigou_id)
    driver.implicitly_wait(20)
    driver.find_element(By.NAME, "mobile").send_keys(mobile_nub)
    driver.implicitly_wait(20)
    driver.find_element(By.NAME, "yzm").send_keys(yzm)
    driver.implicitly_wait(20)
    driver.find_element(By.NAME, "pwd").send_keys("123qwe")
    driver.implicitly_wait(20)
    driver.find_element(By.NAME, "pwd2").send_keys("123qwe")
    driver.implicitly_wait(20)
    driver.find_element(By.XPATH, "/html/body/div[2]/form/input").click()
    print("组织机构代码：",jigou_id)
    print("密码：","123qwe")
    print("手机号",mobile_nub)
    time.sleep(1)
    driver.switch_to.alert.accept()
    driver.implicitly_wait(20)
    driver.get("http://192.168.1.242:8034")
    driver.implicitly_wait(20)
    driver.find_element(By.NAME, "unitcode").send_keys(jigou_id)
    driver.implicitly_wait(20)
    driver.find_element(By.NAME, "pwd").send_keys("123qwe")
    driver.implicitly_wait(20)
    driver.find_element(By.XPATH, "/html/body/div[2]/form/input").click()  #点击确定
    time.sleep(1)
    driver.find_element_by_xpath("/html/body/div[3]/div/img").click() # 填写须知
    driver.implicitly_wait(20)
    driver.find_element(By.NAME,"jgmc").send_keys("技术"+str(randint(1,99999999))+"机构")
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/div[1]/ul/li[4]/span[2]").click()
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[4]/div/img").click()
    driver.implicitly_wait(20)
    Select(driver.find_element_by_name("jglb")).select_by_value("1")
    driver.implicitly_wait(20)
    province_nub = str(randint(0,34))
    Select(driver.find_element_by_xpath('/html/body/div[2]/form/div[1]/ul/li[6]/select[1]')).select_by_value(province_nub) #省份随机
    time.sleep(1)
    city_nub = driver.find_elements_by_xpath("/ html / body / div[2] / form / div[1] / ul / li[6] / select[2] / option")#获取市list
    Select(driver.find_element_by_xpath("/html/body/div[2]/form/div[1]/ul/li[6]/select[2]")).select_by_value(str(randint(0,(len(city_nub)-2)))) #市
    time.sleep(1)
    qu_nub = driver.find_elements_by_xpath("/html/body/div[2]/form/div[1]/ul/li[6]/select[3]/option")#获取区县list
    driver.implicitly_wait(20)
    Select(driver.find_element_by_xpath("/html/body/div[2]/form/div[1]/ul/li[6]/select[3]")).select_by_value(str(randint(0,(len(qu_nub)-2)))) #县
    driver.implicitly_wait(20)
    driver.find_element_by_name("address").send_keys("北京市西城区广安门外大街")
    driver.implicitly_wait(20)
    driver.find_element_by_name("group").send_keys("无")
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/div[2]/ul/li[2]").click()
    time.sleep(1)
    driver.find_element_by_xpath("/html/body/div[5]/div[1]/img").click()
    driver.implicitly_wait(20)
    driver.find_element_by_name("certification").send_keys("医美测试")
    driver.implicitly_wait(20)
    driver.find_element_by_name("email").send_keys(email)
    driver.implicitly_wait(20)
    driver.find_element_by_name("officeTelephone").send_keys(officeTelephone)
    driver.implicitly_wait(20)
    driver.find_element_by_name("cellPhone").send_keys(mobile_nub)
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/input").click()   #下一步
    driver.implicitly_wait(20)
    driver.find_element_by_name("ba").send_keys("500")  #医疗机构总建筑面积 (m²)
    driver.implicitly_wait(20)
    driver.find_element_by_name("ea").send_keys("500")  #医疗机构展开面积 (m²)
    driver.implicitly_wait(20)
    driver.find_element_by_name("ba2").send_keys("500")  #医疗用房建筑面积 (m²)
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/div[2]/ul/li[2]/label[1]/span[2]").click()
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/div[2]/ul/li[2]/label[2]/span[2]").click()
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/div[2]/ul/li[3]/label[1]/span[2]").click()
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/div[2]/ul/li[3]/label[2]/span[2]").click()
    driver.implicitly_wait(20)
    driver.find_element_by_name("bed").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("bed").send_keys("20")
    driver.implicitly_wait(20)
    driver.find_element_by_name("mrbed").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("mrbed").send_keys("20")
    driver.implicitly_wait(20)
    driver.find_element_by_name("ykzly").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("ykzly").send_keys("20")
    driver.implicitly_wait(20)
    driver.find_element_by_name("gccw").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("gccw").send_keys("20")
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/input").click()
    driver.implicitly_wait(20)
    driver.find_element_by_name("totalNumber").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("totalNumber").send_keys("80")
    driver.implicitly_wait(20)
    driver.find_element_by_name("hygienicPersonnel").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("hygienicPersonnel").send_keys("20")
    driver.implicitly_wait(20)
    driver.find_element_by_name("others").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("others").send_keys("10")
    driver.implicitly_wait(20)
    driver.find_element_by_name("doctor").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("doctor").send_keys("10")
    driver.implicitly_wait(20)
    driver.find_element_by_name("anesthesiologist").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("anesthesiologist").send_keys("10")
    driver.implicitly_wait(20)
    driver.find_element_by_name("deputyDirector").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("deputyDirector").send_keys("10")
    driver.implicitly_wait(20)
    driver.find_element_by_name("nurse").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("nurse").send_keys("10")
    driver.implicitly_wait(20)
    driver.find_element_by_name("nursing").clear()
    driver.implicitly_wait(20)
    driver.find_element_by_name("nursing").send_keys("10")
    driver.implicitly_wait(20)
    driver.find_element_by_xpath("/html/body/div[2]/form/input").click()
    time.sleep(1)
    driver.find_element_by_id("upload1").send_keys(file_path+"//pic//112121212121.png")
    time.sleep(1)
    driver.find_element_by_id("upload2").send_keys(file_path+"//pic//112121212121.png")
    time.sleep(1)
    driver.find_element_by_id("upload3").send_keys(file_path+"//pic//112121212121.png")
    time.sleep(1)
    driver.find_element_by_id("upload4").send_keys(file_path+"//pic//112121212121.png")
    time.sleep(1)
    driver.find_element_by_id("upload5").send_keys(file_path+"//pic//112121212121.png")
    time.sleep(1)
    driver.find_element_by_id("upload6").send_keys(file_path+"//pic//112121212121.png")
    time.sleep(1)
    js = "window.scrollTo(0,10000);"
    driver.execute_script(js)
    time.sleep(1)
    driver.find_element_by_xpath("/html/body/div[2]/input").click()
    time.sleep(1)
    driver.find_element_by_id("upload1").send_keys(file_path+"//pic//112121212121.png")
    time.sleep(1)
    driver.find_element_by_xpath("/html/body/div[2]/input").click()
    time.sleep(1)
    driver.find_element_by_xpath("/html/body/div[2]/input").click()   #返回
    time.sleep(1)
    driver.find_element(By.XPATH, "/html/body/div[2]/div[3]/ul/li[3]/p").click()  #机构自评按钮
    time.sleep(1)
    driver.find_element(By.XPATH,"/html/body/div[2]/input").click()  #下一步
    return jigou_id
